package com.peng.leetcode.array;

import java.util.HashSet;
import java.util.Set;

/**
 * FindSubarrays
 * 2395. 和相等的子数组
 * https://leetcode.cn/problems/find-subarrays-with-equal-sum/
 *
 * @author: lupeng6
 * @create: 2023/3/26 20:28
 */
public class FindSubarrays {
    public boolean findSubarrays(int[] nums) {
        Set<Integer> sumSet = new HashSet<>();
        for (int i = 0; i < nums.length - 1; i++) {
            int sum = nums[i] + nums[i + 1];
            if (sumSet.contains(sum)) {
                return true;
            } else {
                sumSet.add(sum);
            }
        }
        return false;
    }
}
